package com.edu.exam.enums.curriculum;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 课程操作类型枚举
 *
 * <p>定义课程管理中的操作类型。</p>
 *
 * @author System
 * @version 1.0.0
 * @since 2025-11-17
 */
public enum OperationType implements BaseEnum {

    CREATE("CREATE", "创建"),
    READ("READ", "读取"),
    UPDATE("UPDATE", "更新"),
    DELETE("DELETE", "删除"),
    APPROVE("APPROVE", "审核"),
    REJECT("REJECT", "拒绝"),
    PUBLISH("PUBLISH", "发布"),
    ARCHIVE("ARCHIVE", "归档"),
    ACTIVATE("ACTIVATE", "激活"),
    DEACTIVATE("DEACTIVATE", "停用");

    private final String code;
    private final String description;

    OperationType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static OperationType fromCode(String code) {
        for (OperationType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown operation type code: " + code);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}
